package com.banmao.Offer.No55;

public class Solution {

    private int max = 0;

    public int maxDepth(TreeNode root) {

        int depth = 0;
        recursive(root, depth);

        return max;
    }

    private void recursive(TreeNode root, int depth) {

        if(root == null) {
            return;
        }

        depth++;
        if(max < depth) {
            max = depth;
        }

        recursive(root.left, depth);
        recursive(root.right, depth);

    }

}

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;

    TreeNode(int x) {
        val = x;
    }
}
